#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 1e5 + 5;
const int B = 131;
using ull = unsigned long long;

string s[3];
int n[3];
ull b[N];
ull f[3][N];
int dp[3][3];
int calc(int x, int y) {
  char c = s[x].back();
  per(i, min(n[x], n[y]), 1) {
    if (s[y][i] != c) continue;
    ull c = f[y][i];
    ull d = f[x][n[x]] - f[x][n[x] - i] * b[i];
    if (c == d) return i;
  }
  return 0;
}
bool check_in(int x, int y) {
  char c = s[x].back();
  rep(i, n[x], n[y]) {
    if (s[y][i] != c) continue;
    ull c = f[x][n[x]];
    ull d = f[y][i] - f[y][i - n[x]] * b[n[x]];
    if (c == d) return true;
  }
  return false;
}
void solve() {
  rep(i, 0, 2) cin >> s[i];
  if (s[0].size() > s[1].size()) swap(s[0], s[1]);
  if (s[0].size() > s[2].size()) swap(s[0], s[2]);
  if (s[1].size() > s[2].size()) swap(s[1], s[2]);
  rep(i, 0, 2) n[i] = s[i].size();
  rep(i, 0, 2) s[i] = ' ' + s[i];
  b[0] = 1;
  rep(i, 1, 1e5) b[i] = b[i - 1] * B;
  rep(i, 0, 2) rep(j, 1, n[i]) f[i][j] = f[i][j - 1] * B + s[i][j];
  rep(i, 0, 2) rep(j, 0, 2) {
    if (i == j) continue;
    dp[i][j] = calc(i, j);
  }
  if (check_in(0, 1) || check_in(0, 2)) {
    cout << n[1] + n[2] - max(dp[1][2], dp[2][1]);
  } else if (check_in(1, 2)) {
    cout << n[0] + n[2] - max(dp[0][2], dp[2][0]);
  } else {
    int tot = n[0] + n[1] + n[2];
    int ans = tot;
    // 0, 1, 2
    ans = min(ans, tot - dp[0][1] - dp[1][2]);
    // 2, 1, 0
    ans = min(ans, tot - dp[2][1] - dp[1][0]);
    // 0, 2, 1
    ans = min(ans, tot - dp[0][2] - dp[2][1]);
    // 1, 2, 0
    ans = min(ans, tot - dp[1][2] - dp[2][0]);
    // 1, 0, 2
    ans = min(ans, tot - dp[1][0] - dp[0][2]);
    // 2, 0, 1
    ans = min(ans, tot - dp[2][0] - dp[0][1]);
    cout << ans;
  }
  return;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t = 1;
  while (t--) solve();
  return 0;
}